<?php
// Header Cache infomation
header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

define('IS_ADMIN', true);
require '../config.php';
require '../libs/class.login.php';
require '../libs/function.php';
require 'language.php';

$log = new logmein();
$log->checklogin();

// Referer url
$referer = $_SERVER["HTTP_REFERER"];

// Value POST
$submit = isset($_POST['submit']) ? strval($_POST['submit']) : NULL;

// Get Value from URL
$mod = isset($_GET['mod']) ? strval($_GET['mod']) : 'index';
$act = isset($_GET['act']) ? strval($_GET['act']) : NULL;
$keyword = isset($_GET['keyword']) ? strval($_GET['keyword']) : NULL;
$popular = isset($_GET['popular']) ? intval($_GET['popular']) : 0;
$active = isset($_GET['active']) ? intval($_GET['active']) : 1;

// ID of Games or Cateogries
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;

// For pagination
$limit = 10;
$page = isset($_GET['p']) ? intval($_GET['p']) : 1;

if ($page <= 0)
	$page = 1;
$start = ($page - 1) * $limit;

switch ($mod){
	case 'index':
		require 'mod/games.php';
	break;
	case 'games':
		switch ($act){
			case 'create':
				require 'mod/games_create.php';
			break;
			case 'edit':
				require 'mod/games_edit.php';
			break;
			default:
				require 'mod/games.php';
			break;
		}
	break;
	case 'category':
		switch ($act){
			case 'create':
				require 'mod/category_create.php';
			break;
			case 'edit':
				require 'mod/category_edit.php';
			break;
			default:
				require 'mod/category.php';
			break;
		}
	break;
	case 'logout':
		$log->logout();
	break;
	default:
		header('HTTP/1.1 404 Not Found');
		die('404 - Not Found');
	break;
}